﻿package mortal.game.view.pack.social
{
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.mvc.interfaces.*;

    public class ReNameCardUseWin extends SmallWindow
    {
        private var _teamName:GTextInput;
        private var _btnOK:GButton;
        private var _btnCancel:GButton;
        private var _itemData:ItemData;
        private static var _instance:ReNameCardUseWin;

        public function ReNameCardUseWin(param1:ILayer = null)
        {
            super(param1);
            this.setSize(260, 160);
            this.title = Language.getString(35485);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = GlobalStyle.textFormatHuang2;
            _loc_1.size = 13;
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(35486), 25, 45, 150, 25, this, _loc_1));
            this._teamName = UIFactory.gTextInput(76, 78, 120, 22, this);
            this._teamName.maxChars = 7;
            this._teamName.defaultText = Language.getString(35487);
            this._teamName.restrict = "一-龥 -~·-=【】；‘、，。、.~！@#￥%……&*（）——+{}：’“”|《》？/*.‘’";
            this._btnOK = UIFactory.gButton(Language.getString(30026), 62, 115, 49, 28, this);
            this._btnOK.configEventListener(MouseEvent.CLICK, this.clickBtnHandler);
            this._btnCancel = UIFactory.gButton(Language.getString(30027), 162, 115, 49, 28, this);
            this._btnCancel.configEventListener(MouseEvent.CLICK, this.clickBtnHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._teamName.dispose(param1);
            this._teamName = null;
            this._btnOK.dispose(param1);
            this._btnOK = null;
            this._btnCancel.dispose(param1);
            this._btnCancel = null;
            this._itemData = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function clickBtnHandler(event:MouseEvent) : void
        {
            var e:* = event;
            if (e.target == this._btnOK)
            {
                var closeAlert:* = function (param1:int) : void
            {
                if (param1 == Alert.OK)
                {
                    GameProxy.role.changeName(_teamName.text, _itemData.uid);
                }
                return;
            }// end function
            ;
                if (this._teamName.text == "" || this._teamName.text == this._teamName.defaultText)
                {
                    return MsgManager.showRollTipsMsg(Language.getString(35488), MsgRollTipsType.msgRollTips3);
                }
                if (this._teamName.text == Cache.instance.role.entityInfo.name)
                {
                    return MsgManager.showRollTipsMsg(Language.getString(35489), MsgRollTipsType.msgRollTips3);
                }
                Alert.isFlowMouse = true;
                Alert.show(Language.getString(35490) + this._teamName.text + "</font>", null, Alert.OK | Alert.CANCEL, null, closeAlert, null, 4);
            }
            else if (e.target == this._btnCancel)
            {
                this.hide();
            }
            return;
        }// end function

        public function set itemData(param1:ItemData) : void
        {
            this._itemData = param1;
            return;
        }// end function

        public static function get instance() : ReNameCardUseWin
        {
            if (_instance == null)
            {
                _instance = new ReNameCardUseWin;
            }
            return _instance;
        }// end function

        public static function get isViewShow() : Boolean
        {
            return _instance && !_instance.isHide;
        }// end function

    }
}
